package com.example.shortbread;

import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Text;
import shortbread.Shortcut;

/**
 * BooksAbility
 *
 * @date 2021/5/27
 */
@Shortcut(id = "books", hostAbility = "com.example.shortbread.MainAbility",
        icon = ResourceTable.Media_ic_shortcut_books,
        shortLabelRes = ResourceTable.String_label_books, rank = 1)
public class BooksAbility extends Ability {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        setUIContent(ResourceTable.Layout_ability_books);
    }

    /**
     * showFavoriteBooks 注解生成对应的shortcut
     */
    @Shortcut(id = "favorite_books", hostAbility = "com.example.shortbread.MainAbility",
            icon = ResourceTable.Media_ic_shortcut_favorite, shortLabel = "Favorite books",
            rank = 2, disabledMessage = "You have no favorite books")
    public void showFavoriteBooks() {
        ((Text) findComponentById(ResourceTable.Id_text)).setText("Favorite books");
    }


}
